package com.jrx.anytxn.transaction.service;


import com.jrx.anytxn.common.exception.TxnBizException;
import com.jrx.anytxn.common.exception.TxnException;
import com.jrx.anytxn.i18n.response.TxnPage;
import com.jrx.anytxn.transaction.dto.interfaceinfo.GlInterfaceInfoRes;
import com.jrx.anytxn.transaction.dto.loan.GlInterfaceReq;
import com.jrx.anytxn.transaction.dto.loan.GlInterfaceRes;
import com.jrx.anytxn.transaction.dto.loan.RecordGlInterfaceReq;
import com.jrx.anytxn.transaction.dto.loan.RecordGlInterfaceRes;
import com.jrx.anytxn.transaction.entity.*;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

public interface IGlInterfaceService {

    /**
     * 计提账户  生成计提gl
     *
     * @param businessDate
     * @param amInterestAccrualInfo
     * @return
     */
    TlGlInterfaceInfo generateGlInterfaceForAcccrual(Date businessDate, AmInterestAccrualInfo amInterestAccrualInfo) throws TxnException;

    /**
     * 计提账户  生成税金计提gl
     *
     * @param businessDate
     * @param amInterestAccrualInfo
     * @return
     */
    TlGlInterfaceInfo generateGlInterfaceForAcccrualTax(Date businessDate, AmInterestAccrualInfo amInterestAccrualInfo) throws TxnException;

    /**
     * 分页查询总账流水表信息
     *
     * @param tenantId 租户id
     * @param pageNum  页码
     * @param pageSize 页大小
     * @return com.jrx.anytxn.common.data.TxnPage<com.jrx.anytxn.transaction.dto.interfaceinfo.GlInterfaceInfoRes>
     * @author: fan.yang
     * @date: 2019/9/24 0024 上午 11:26
     */
    TxnPage<GlInterfaceInfoRes> getGlInterfaceInfoByPage(String tenantId, Integer pageNum, Integer pageSize, String customerId, String loanId) throws TxnBizException;

    /**
     * 按主键查询总账流水表信息
     *
     * @param id         主键ID
     * @param customerId 客户ID
     * @param tenantId   租户ID
     * @return com.jrx.anytxn.transaction.dto.interfaceinfo.GlInterfaceInfoRes
     * @author: fan.yang
     * @date: 2019/9/24 0024 上午 11:26
     */
    GlInterfaceInfoRes getGlInterfaceInfoByPrimaryKey(Long id, String tenantId, String customerId) throws TxnBizException;

    /**
     * 生成09账户对应的gl流水
     *
     * @param paymentLog
     * @return
     */
    TlGlInterfaceInfo buildTlGlInterfaceInfo(TlPaymentAllocationLog paymentLog) throws TxnException;

    /**
     * 生成09账户对应的gl流水
     *
     * @param paymentLogList
     * @param loanMainInfo
     * @param loanAccountInfo
     * @return
     * @throws TxnException
     */
    List<TlGlInterfaceInfo> buildTlGlInterfaceInfoList(List<TlPaymentAllocationLog> paymentLogList, AmLoanMainInfo loanMainInfo, AmLoanAccountInfo loanAccountInfo) throws TxnException;

    /**
     * 生成09账户对应的gl流水
     *
     * @param paymentLogList
     * @param loanMainInfoList
     * @param loanAccountInfoList
     * @return
     * @throws TxnException
     */
    List<TlGlInterfaceInfo> buildTlGlInterfaceInfoList(List<TlPaymentAllocationLog> paymentLogList, List<AmLoanMainInfo> loanMainInfoList, List<AmLoanAccountInfo> loanAccountInfoList) throws TxnException;

    /**
     * 贷款时总账流水生成
     *
     * @param amLoanMainInfo    贷款信息
     * @param amLoanAccountInfo 贷款账户信息
     * @param productName       产品名称
     * @param business          业务日期
     * @param liabilityFlag     债务归属
     * @return gl流水
     */
    TlGlInterfaceInfo buildTlGlInterfaceInfo(AmLoanMainInfo amLoanMainInfo, AmLoanAccountInfo amLoanAccountInfo,
                                             String productName, Date business, String liabilityFlag) throws TxnException;

    /**
     * 交易账户生成GL
     *
     * @param amAccountMainInfo
     * @param glAmt
     * @param txnCode
     * @param orgiStatus
     * @param business
     * @return
     * @throws TxnException
     */
    TlGlInterfaceInfo buildTlGlInterfaceInfo(AmAccountMainInfo amAccountMainInfo, BigDecimal glAmt, String txnCode, String orgiStatus,
                                             Date business) throws TxnException;

    /**
     * 累计账户生成成GL
     *
     * @param amInterestAccrualInfo
     * @param txnCode
     * @param orgiStatus
     * @param business
     * @return
     * @throws TxnException
     */
    TlGlInterfaceInfo buildTlGlInterfaceInfo(AmInterestAccrualInfo amInterestAccrualInfo, BigDecimal glAmt, String txnCode, String orgiStatus,
                                             Date business) throws TxnException;

    /**
     * 累计账户转列生成GL
     *
     * @param amInterestAccrualInfo
     * @param txnCode
     * @param orgiStatus
     * @param business
     * @return
     * @throws TxnException
     */
    TlGlInterfaceInfo buildTlGlInterfaceInfo(AmInterestAccrualInfo amInterestAccrualInfo, String txnCode, String orgiStatus,
                                             Date business) throws TxnException;

    /**
     * 订单生成GL
     *
     * @param amLoanAccountInfo
     * @param amLoanMainInfo
     * @param txnCode
     * @param orgiStatus
     * @param bussinessDate
     * @param prinNonAccrualFlag 本金转非应计标志  0不转列  1转列
     * @return
     * @throws TxnException
     */
    TlGlInterfaceInfo buildTlGlInterfaceInfo(AmLoanAccountInfo amLoanAccountInfo, AmLoanMainInfo amLoanMainInfo, String txnCode,
                                             String orgiStatus, Date bussinessDate, String prinNonAccrualFlag) throws TxnException;

    /**
     * 生成取消订单GL
     *
     * @param orgiGl
     * @param businessDate
     * @return
     */
    TlGlInterfaceInfo buildTlGlInterfaceInfo(TlGlInterfaceInfo orgiGl, Date businessDate) throws TxnException;


    TlGlInterfaceInfo buildTlGlInterfaceInfo(String productId, String tenantId, String orgId, String txnCode, BigDecimal glAmt, String classify, Date businessDate) throws TxnException;


    GlInterfaceRes buildTlGlInterfaceInfo(GlInterfaceReq req) throws TxnException;

    /**
     * 交易账户税金生成GL
     *
     * @param amAccountMainInfo
     * @param intrAmt
     * @param taxAmt
     * @param txnCode
     * @param orgiStatus
     * @param business
     * @return
     * @throws TxnException
     */
    TlGlInterfaceInfo buildTaxTlGlInterfaceInfo(AmAccountMainInfo amAccountMainInfo, BigDecimal intrAmt, BigDecimal taxAmt, String txnCode, String orgiStatus,
                                                Date business) throws TxnException;

    /**
     * 累计账户税金生成gl
     *
     * @param amInterestAccrualInfo
     * @param intrAmt
     * @param taxAmt
     * @param txnCode
     * @param orgiStatus
     * @param business
     * @return
     */
    TlGlInterfaceInfo buildTaxTlGlInterfaceInfo(AmInterestAccrualInfo amInterestAccrualInfo, BigDecimal intrAmt, BigDecimal taxAmt, String txnCode, String orgiStatus, Date business) throws TxnException;

    /**
     * 总账流水记账
     *
     * @param req 总账流水记账请求
     * @return RecordGlInterfaceRes
     * @throws TxnException
     */
    RecordGlInterfaceRes buildTlGlInterfaceInfo(RecordGlInterfaceReq req) throws TxnException;

    /**
     * 生成退款溢缴款gl流水
     *
     * @param amLoanMainInfo
     * @param business
     * @return
     * @throws TxnException
     */
    TlGlInterfaceInfo buildRefundGl(AmLoanMainInfo amLoanMainInfo, BigDecimal refundAmt, Date business) throws TxnException;

}
